/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package proyecto2.vista;

import java.util.ArrayList;
import proyecto2.logica.DFA;
import proyecto2.logica.Estado;
import proyecto2.logica.StringGenerator;
import proyecto2.logica.Transicion;

/**
 *
 * @author jvm
 */
public class ventana0 extends javax.swing.JFrame {

    /**
     * Creates new form ventana0
     */
    public ventana0() {
        initComponents();
        this.setLocationRelativeTo(null);
        this.recognize.setVisible(false);
        this.recognize.setEnabled(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        all0 = new javax.swing.JPanel();
        automaticos = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jpDraw = new javax.swing.JPanel();
        draw = new javax.swing.JButton();
        jpDrawIn = new javax.swing.JPanel();
        jpMix = new javax.swing.JPanel();
        mix = new javax.swing.JButton();
        jpMixIn = new javax.swing.JPanel();
        jpHilera = new javax.swing.JPanel();
        gen = new javax.swing.JButton();
        recognize = new javax.swing.JButton();
        jpHileraIn = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        inputExpresion = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        espacioHilera = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        all0.setBackground(new java.awt.Color(0, 0, 0));

        automaticos.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        automaticos.setForeground(new java.awt.Color(51, 255, 51));
        automaticos.setText("Automaticos");

        draw.setBackground(new java.awt.Color(51, 255, 51));
        draw.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
        draw.setForeground(new java.awt.Color(0, 0, 0));
        draw.setText("Dibujar");
        draw.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                drawMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jpDrawInLayout = new javax.swing.GroupLayout(jpDrawIn);
        jpDrawIn.setLayout(jpDrawInLayout);
        jpDrawInLayout.setHorizontalGroup(
            jpDrawInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jpDrawInLayout.setVerticalGroup(
            jpDrawInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 374, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jpDrawLayout = new javax.swing.GroupLayout(jpDraw);
        jpDraw.setLayout(jpDrawLayout);
        jpDrawLayout.setHorizontalGroup(
            jpDrawLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpDrawLayout.createSequentialGroup()
                .addGap(289, 289, 289)
                .addComponent(draw)
                .addContainerGap(302, Short.MAX_VALUE))
            .addComponent(jpDrawIn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpDrawLayout.setVerticalGroup(
            jpDrawLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpDrawLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpDrawIn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(draw)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Dibujar", jpDraw);

        mix.setBackground(new java.awt.Color(51, 255, 51));
        mix.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
        mix.setForeground(new java.awt.Color(0, 0, 0));
        mix.setText("Mix");
        mix.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mixMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jpMixInLayout = new javax.swing.GroupLayout(jpMixIn);
        jpMixIn.setLayout(jpMixInLayout);
        jpMixInLayout.setHorizontalGroup(
            jpMixInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jpMixInLayout.setVerticalGroup(
            jpMixInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 380, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jpMixLayout = new javax.swing.GroupLayout(jpMix);
        jpMix.setLayout(jpMixLayout);
        jpMixLayout.setHorizontalGroup(
            jpMixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpMixLayout.createSequentialGroup()
                .addContainerGap(310, Short.MAX_VALUE)
                .addComponent(mix)
                .addGap(305, 305, 305))
            .addComponent(jpMixIn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpMixLayout.setVerticalGroup(
            jpMixLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpMixLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpMixIn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mix)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Mix", jpMix);

        gen.setBackground(new java.awt.Color(51, 255, 51));
        gen.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
        gen.setForeground(new java.awt.Color(0, 0, 0));
        gen.setText("Generar");
        gen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                genMouseClicked(evt);
            }
        });

        recognize.setBackground(new java.awt.Color(51, 255, 51));
        recognize.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
        recognize.setForeground(new java.awt.Color(0, 0, 0));
        recognize.setText("Reconocer");
        recognize.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                recognizeMouseClicked(evt);
            }
        });

        jLabel1.setText("Expresión Regular");

        inputExpresion.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N

        jLabel2.setText("Hilera");

        javax.swing.GroupLayout jpHileraInLayout = new javax.swing.GroupLayout(jpHileraIn);
        jpHileraIn.setLayout(jpHileraInLayout);
        jpHileraInLayout.setHorizontalGroup(
            jpHileraInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpHileraInLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpHileraInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jpHileraInLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(inputExpresion, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2)
                    .addComponent(espacioHilera))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpHileraInLayout.setVerticalGroup(
            jpHileraInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpHileraInLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpHileraInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(inputExpresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(espacioHilera, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(259, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jpHileraLayout = new javax.swing.GroupLayout(jpHilera);
        jpHilera.setLayout(jpHileraLayout);
        jpHileraLayout.setHorizontalGroup(
            jpHileraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpHileraLayout.createSequentialGroup()
                .addGap(187, 187, 187)
                .addComponent(gen)
                .addGap(116, 116, 116)
                .addComponent(recognize)
                .addContainerGap(193, Short.MAX_VALUE))
            .addComponent(jpHileraIn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpHileraLayout.setVerticalGroup(
            jpHileraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpHileraLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpHileraIn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(19, 19, 19)
                .addGroup(jpHileraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gen)
                    .addComponent(recognize))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Hileras", jpHilera);

        javax.swing.GroupLayout all0Layout = new javax.swing.GroupLayout(all0);
        all0.setLayout(all0Layout);
        all0Layout.setHorizontalGroup(
            all0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(all0Layout.createSequentialGroup()
                .addGap(253, 253, 253)
                .addComponent(automaticos)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jTabbedPane1)
        );
        all0Layout.setVerticalGroup(
            all0Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, all0Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(automaticos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(all0, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(all0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void drawMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_drawMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_drawMouseClicked

    private void mixMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mixMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_mixMouseClicked

    private void genMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_genMouseClicked
        this.recognize.setVisible(true);
        this.recognize.setEnabled(true);
        StringGenerator generador = new StringGenerator(this.inputExpresion.getText());
        this.espacioHilera.setText(generador.interpreta());


    }//GEN-LAST:event_genMouseClicked

    private void recognizeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recognizeMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_recognizeMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ventana0.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ventana0.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ventana0.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ventana0.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventana0().setVisible(true);
            }
        });
    }

//    private DFA creaDFA()
//    {
//        ArrayList<Estado> esta = new ArrayList<>();
//        esta.add(new Estado("X",false,true));
//        esta.add(new Estado("Y",true,false));
//        ArrayList<String> alf = new ArrayList<>();
//        alf.add("0");
//        alf.add("1");
//        ArrayList<Transicion> tr = new ArrayList<>(); 
//        tr.add(new Transicion(new Estado("X",false,true),"0", new Estado("Y",true,false) ));
//        tr.add(new Transicion(new Estado("X",false,true),"1", new Estado("Y",true,false) ));
//        tr.add(new Transicion(new Estado("Y",true,false),"0", new Estado("X",false,true) )); 
//        tr.add(new Transicion(new Estado("Y",true,false),"1", new Estado("Y",true,false) )); 
//        Estado i = new Estado("X",false,true);
//        ArrayList<Estado> fs = new ArrayList<>(); 
//        fs.add(new Estado("Y",true,false)); 
//        return new DFA(esta,alf)
//    }
    private DFA dfa;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel all0;
    private javax.swing.JLabel automaticos;
    private javax.swing.JButton draw;
    private javax.swing.JTextField espacioHilera;
    private javax.swing.JButton gen;
    private javax.swing.JTextField inputExpresion;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel jpDraw;
    private javax.swing.JPanel jpDrawIn;
    private javax.swing.JPanel jpHilera;
    private javax.swing.JPanel jpHileraIn;
    private javax.swing.JPanel jpMix;
    private javax.swing.JPanel jpMixIn;
    private javax.swing.JButton mix;
    private javax.swing.JButton recognize;
    // End of variables declaration//GEN-END:variables
}
